package com.zik.rader_and_video.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zik.rader_and_video.config.MyResponse;
import com.zik.rader_and_video.po.Errors;
import com.zik.rader_and_video.service.IErrorsService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author zik
 * @description
 * @time 2023/6/21 15:19
 **/
@RestController
@RequestMapping("/errors")
public class ErrorController {

    @Resource(name = "IErrorsService")
    private IErrorsService errorsService;

    @GetMapping("pageErrors/{page}/{pageSize}")
    public MyResponse<Page<Errors>> getPage(@PathVariable Integer page,
                                          @PathVariable Integer pageSize) {
        LambdaQueryWrapper<Errors> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper
                .orderByDesc(Errors::getCreateTime);
        return MyResponse.success(errorsService.page(new Page<>(page, pageSize), queryWrapper));
    }

}
